using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using OVS.BusinessObjects;

namespace OVS.DAL
{
	public partial class AlertDAO
	{
		public AlertDAO()
		{
			DbProviderHelper.GetConnection();
		}
		public List<Alert> GetAlerts()
		{
			try
			{
				List<Alert> lstAlerts = new List<Alert>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [aler_id],[came_id],[aler_dt],[aler_lvl],[aler_status],[aler_image_traj],[vide_id],[aler_image],[imde_id],[user_id] FROM [Alert]",CommandType.Text);
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					Alert oAlert = new Alert();
					oAlert.aler_id = Convert.ToInt32(oDbDataReader["aler_id"]);

					if(oDbDataReader["came_id"] != DBNull.Value)
						oAlert.came_id = Convert.ToInt32(oDbDataReader["came_id"]);

					if(oDbDataReader["aler_dt"] != DBNull.Value)
						oAlert.aler_dt = Convert.ToDateTime(oDbDataReader["aler_dt"]);

					if(oDbDataReader["aler_lvl"] != DBNull.Value)
						oAlert.aler_lvl = Convert.ToInt32(oDbDataReader["aler_lvl"]);

					if(oDbDataReader["aler_status"] != DBNull.Value)
						oAlert.aler_status = Convert.ToBoolean(oDbDataReader["aler_status"]);

					if(oDbDataReader["aler_image_traj"] != DBNull.Value)
						oAlert.aler_image_traj = Convert.ToString(oDbDataReader["aler_image_traj"]);

					if(oDbDataReader["vide_id"] != DBNull.Value)
						oAlert.vide_id = Convert.ToInt32(oDbDataReader["vide_id"]);

					if(oDbDataReader["aler_image"] != DBNull.Value)
						oAlert.aler_image = Convert.ToString(oDbDataReader["aler_image"]);

					if(oDbDataReader["imde_id"] != DBNull.Value)
						oAlert.imde_id = Convert.ToInt32(oDbDataReader["imde_id"]);

					if(oDbDataReader["user_id"] != DBNull.Value)
						oAlert.user_id = Convert.ToInt32(oDbDataReader["user_id"]);
					lstAlerts.Add(oAlert);
				}
				oDbDataReader.Close();
				return lstAlerts;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public Alert GetAlert(int aler_id)
		{
			try
			{
				Alert oAlert = new Alert();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [aler_id],[came_id],[aler_dt],[aler_lvl],[aler_status],[aler_image_traj],[vide_id],[aler_image],[imde_id],[user_id] FROM [Alert] WHERE [aler_id]=@aler_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_id",DbType.Int32,aler_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oAlert.aler_id = Convert.ToInt32(oDbDataReader["aler_id"]);

					if(oDbDataReader["came_id"] != DBNull.Value)
						oAlert.came_id = Convert.ToInt32(oDbDataReader["came_id"]);

					if(oDbDataReader["aler_dt"] != DBNull.Value)
						oAlert.aler_dt = Convert.ToDateTime(oDbDataReader["aler_dt"]);

					if(oDbDataReader["aler_lvl"] != DBNull.Value)
						oAlert.aler_lvl = Convert.ToInt32(oDbDataReader["aler_lvl"]);

					if(oDbDataReader["aler_status"] != DBNull.Value)
						oAlert.aler_status = Convert.ToBoolean(oDbDataReader["aler_status"]);

					if(oDbDataReader["aler_image_traj"] != DBNull.Value)
						oAlert.aler_image_traj = Convert.ToString(oDbDataReader["aler_image_traj"]);

					if(oDbDataReader["vide_id"] != DBNull.Value)
						oAlert.vide_id = Convert.ToInt32(oDbDataReader["vide_id"]);

					if(oDbDataReader["aler_image"] != DBNull.Value)
						oAlert.aler_image = Convert.ToString(oDbDataReader["aler_image"]);

					if(oDbDataReader["imde_id"] != DBNull.Value)
						oAlert.imde_id = Convert.ToInt32(oDbDataReader["imde_id"]);

					if(oDbDataReader["user_id"] != DBNull.Value)
						oAlert.user_id = Convert.ToInt32(oDbDataReader["user_id"]);
				}
				oDbDataReader.Close();
				return oAlert;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddAlert(Alert oAlert)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERT INTO [Alert]([came_id],[aler_dt],[aler_lvl],[aler_status],[aler_image_traj],[vide_id],[aler_image],[imde_id],[user_id])VALUES(@came_id,@aler_dt,@aler_lvl,@aler_status,@aler_image_traj,@vide_id,@aler_image,@imde_id,@user_id);SELECT SCOPE_IDENTITY();",CommandType.Text);
				if (oAlert.came_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@came_id",DbType.Int32,oAlert.came_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@came_id",DbType.Int32,DBNull.Value));
				if (oAlert.aler_dt.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_dt",DbType.DateTime,oAlert.aler_dt));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_dt",DbType.DateTime,DBNull.Value));
				if (oAlert.aler_lvl.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_lvl",DbType.Int32,oAlert.aler_lvl));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_lvl",DbType.Int32,DBNull.Value));
				if (oAlert.aler_status.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_status",DbType.Boolean,oAlert.aler_status));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_status",DbType.Boolean,DBNull.Value));
				if (oAlert.aler_image_traj!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image_traj",DbType.String,oAlert.aler_image_traj));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image_traj",DbType.String,DBNull.Value));
				if (oAlert.vide_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@vide_id",DbType.Int32,oAlert.vide_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@vide_id",DbType.Int32,DBNull.Value));
				if (oAlert.aler_image!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image",DbType.String,oAlert.aler_image));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image",DbType.String,DBNull.Value));
				if (oAlert.imde_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@imde_id",DbType.Int32,oAlert.imde_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@imde_id",DbType.Int32,DBNull.Value));
				if (oAlert.user_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@user_id",DbType.Int32,oAlert.user_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@user_id",DbType.Int32,DBNull.Value));

				return Convert.ToInt32(DbProviderHelper.ExecuteScalar(oDbCommand));
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateAlert(Alert oAlert)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATE [Alert] SET [came_id]=@came_id,[aler_dt]=@aler_dt,[aler_lvl]=@aler_lvl,[aler_status]=@aler_status,[aler_image_traj]=@aler_image_traj,[vide_id]=@vide_id,[aler_image]=@aler_image,[imde_id]=@imde_id,[user_id]=@user_id WHERE [aler_id]=@aler_id",CommandType.Text);
				if (oAlert.came_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@came_id",DbType.Int32,oAlert.came_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@came_id",DbType.Int32,DBNull.Value));
				if (oAlert.aler_dt.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_dt",DbType.DateTime,oAlert.aler_dt));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_dt",DbType.DateTime,DBNull.Value));
				if (oAlert.aler_lvl.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_lvl",DbType.Int32,oAlert.aler_lvl));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_lvl",DbType.Int32,DBNull.Value));
				if (oAlert.aler_status.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_status",DbType.Boolean,oAlert.aler_status));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_status",DbType.Boolean,DBNull.Value));
				if (oAlert.aler_image_traj!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image_traj",DbType.String,oAlert.aler_image_traj));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image_traj",DbType.String,DBNull.Value));
				if (oAlert.vide_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@vide_id",DbType.Int32,oAlert.vide_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@vide_id",DbType.Int32,DBNull.Value));
				if (oAlert.aler_image!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image",DbType.String,oAlert.aler_image));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_image",DbType.String,DBNull.Value));
				if (oAlert.imde_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@imde_id",DbType.Int32,oAlert.imde_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@imde_id",DbType.Int32,DBNull.Value));
				if (oAlert.user_id.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@user_id",DbType.Int32,oAlert.user_id));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@user_id",DbType.Int32,DBNull.Value));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_id",DbType.Int32,oAlert.aler_id));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveAlert(Alert oAlert)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [Alert] WHERE [aler_id]=@aler_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_id",DbType.Int32,oAlert.aler_id));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveAlert(int aler_id)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [Alert] WHERE [aler_id]=@aler_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@aler_id",DbType.Int32,aler_id));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public List<Alert> GetAlertsOfCamera(int came_id)
		{
			try
			{
				List<Alert> lstAlerts = new List<Alert>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [aler_id],[came_id],[aler_dt],[aler_lvl],[aler_status],[aler_image_traj],[vide_id],[aler_image],[imde_id],[user_id] FROM [Alert] WHERE [came_id]=@came_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@came_id",DbType.Int32,came_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					Alert oAlert = new Alert();
					oAlert.aler_id = Convert.ToInt32(oDbDataReader["aler_id"]);

					if(oDbDataReader["came_id"] != DBNull.Value)
						oAlert.came_id = Convert.ToInt32(oDbDataReader["came_id"]);

					if(oDbDataReader["aler_dt"] != DBNull.Value)
						oAlert.aler_dt = Convert.ToDateTime(oDbDataReader["aler_dt"]);

					if(oDbDataReader["aler_lvl"] != DBNull.Value)
						oAlert.aler_lvl = Convert.ToInt32(oDbDataReader["aler_lvl"]);

					if(oDbDataReader["aler_status"] != DBNull.Value)
						oAlert.aler_status = Convert.ToBoolean(oDbDataReader["aler_status"]);

					if(oDbDataReader["aler_image_traj"] != DBNull.Value)
						oAlert.aler_image_traj = Convert.ToString(oDbDataReader["aler_image_traj"]);

					if(oDbDataReader["vide_id"] != DBNull.Value)
						oAlert.vide_id = Convert.ToInt32(oDbDataReader["vide_id"]);

					if(oDbDataReader["aler_image"] != DBNull.Value)
						oAlert.aler_image = Convert.ToString(oDbDataReader["aler_image"]);

					if(oDbDataReader["imde_id"] != DBNull.Value)
						oAlert.imde_id = Convert.ToInt32(oDbDataReader["imde_id"]);

					if(oDbDataReader["user_id"] != DBNull.Value)
						oAlert.user_id = Convert.ToInt32(oDbDataReader["user_id"]);
					lstAlerts.Add(oAlert);
				}
				oDbDataReader.Close();
				return lstAlerts;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public Camera GetCameraOfAlert(int came_id)
		{
			try
			{
				Camera oCamera = new Camera();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [came_id],[came_loc],[came_url],[came_desc],[came_nom],[came_use] FROM [Camera] WHERE [came_id]=@came_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@came_id",DbType.Int32,came_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oCamera.came_id = Convert.ToInt32(oDbDataReader["came_id"]);
					oCamera.came_loc = Convert.ToString(oDbDataReader["came_loc"]);
					oCamera.came_url = Convert.ToString(oDbDataReader["came_url"]);

					if(oDbDataReader["came_desc"] != DBNull.Value)
						oCamera.came_desc = Convert.ToString(oDbDataReader["came_desc"]);

					if(oDbDataReader["came_nom"] != DBNull.Value)
						oCamera.came_nom = Convert.ToString(oDbDataReader["came_nom"]);

					if(oDbDataReader["came_use"] != DBNull.Value)
						oCamera.came_use = Convert.ToBoolean(oDbDataReader["came_use"]);
				}
				oDbDataReader.Close();
				return oCamera;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public List<Alert> GetAlertsOfVideo(int vide_id)
		{
			try
			{
				List<Alert> lstAlerts = new List<Alert>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [aler_id],[came_id],[aler_dt],[aler_lvl],[aler_status],[aler_image_traj],[vide_id],[aler_image],[imde_id],[user_id] FROM [Alert] WHERE [vide_id]=@vide_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@vide_id",DbType.Int32,vide_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					Alert oAlert = new Alert();
					oAlert.aler_id = Convert.ToInt32(oDbDataReader["aler_id"]);

					if(oDbDataReader["came_id"] != DBNull.Value)
						oAlert.came_id = Convert.ToInt32(oDbDataReader["came_id"]);

					if(oDbDataReader["aler_dt"] != DBNull.Value)
						oAlert.aler_dt = Convert.ToDateTime(oDbDataReader["aler_dt"]);

					if(oDbDataReader["aler_lvl"] != DBNull.Value)
						oAlert.aler_lvl = Convert.ToInt32(oDbDataReader["aler_lvl"]);

					if(oDbDataReader["aler_status"] != DBNull.Value)
						oAlert.aler_status = Convert.ToBoolean(oDbDataReader["aler_status"]);

					if(oDbDataReader["aler_image_traj"] != DBNull.Value)
						oAlert.aler_image_traj = Convert.ToString(oDbDataReader["aler_image_traj"]);

					if(oDbDataReader["vide_id"] != DBNull.Value)
						oAlert.vide_id = Convert.ToInt32(oDbDataReader["vide_id"]);

					if(oDbDataReader["aler_image"] != DBNull.Value)
						oAlert.aler_image = Convert.ToString(oDbDataReader["aler_image"]);

					if(oDbDataReader["imde_id"] != DBNull.Value)
						oAlert.imde_id = Convert.ToInt32(oDbDataReader["imde_id"]);

					if(oDbDataReader["user_id"] != DBNull.Value)
						oAlert.user_id = Convert.ToInt32(oDbDataReader["user_id"]);
					lstAlerts.Add(oAlert);
				}
				oDbDataReader.Close();
				return lstAlerts;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public Video GetVideoOfAlert(int vide_id)
		{
			try
			{
				Video oVideo = new Video();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [vide_id],[vide_fn] FROM [Video] WHERE [vide_id]=@vide_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@vide_id",DbType.Int32,vide_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oVideo.vide_id = Convert.ToInt32(oDbDataReader["vide_id"]);
					oVideo.vide_fn = Convert.ToString(oDbDataReader["vide_fn"]);
				}
				oDbDataReader.Close();
				return oVideo;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public List<Alert> GetAlertsOfImage_Details(int imde_id)
		{
			try
			{
				List<Alert> lstAlerts = new List<Alert>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [aler_id],[came_id],[aler_dt],[aler_lvl],[aler_status],[aler_image_traj],[vide_id],[aler_image],[imde_id],[user_id] FROM [Alert] WHERE [imde_id]=@imde_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@imde_id",DbType.Int32,imde_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					Alert oAlert = new Alert();
					oAlert.aler_id = Convert.ToInt32(oDbDataReader["aler_id"]);

					if(oDbDataReader["came_id"] != DBNull.Value)
						oAlert.came_id = Convert.ToInt32(oDbDataReader["came_id"]);

					if(oDbDataReader["aler_dt"] != DBNull.Value)
						oAlert.aler_dt = Convert.ToDateTime(oDbDataReader["aler_dt"]);

					if(oDbDataReader["aler_lvl"] != DBNull.Value)
						oAlert.aler_lvl = Convert.ToInt32(oDbDataReader["aler_lvl"]);

					if(oDbDataReader["aler_status"] != DBNull.Value)
						oAlert.aler_status = Convert.ToBoolean(oDbDataReader["aler_status"]);

					if(oDbDataReader["aler_image_traj"] != DBNull.Value)
						oAlert.aler_image_traj = Convert.ToString(oDbDataReader["aler_image_traj"]);

					if(oDbDataReader["vide_id"] != DBNull.Value)
						oAlert.vide_id = Convert.ToInt32(oDbDataReader["vide_id"]);

					if(oDbDataReader["aler_image"] != DBNull.Value)
						oAlert.aler_image = Convert.ToString(oDbDataReader["aler_image"]);

					if(oDbDataReader["imde_id"] != DBNull.Value)
						oAlert.imde_id = Convert.ToInt32(oDbDataReader["imde_id"]);

					if(oDbDataReader["user_id"] != DBNull.Value)
						oAlert.user_id = Convert.ToInt32(oDbDataReader["user_id"]);
					lstAlerts.Add(oAlert);
				}
				oDbDataReader.Close();
				return lstAlerts;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public Image_Details GetImage_DetailsOfAlert(int imde_id)
		{
			try
			{
				Image_Details oImage_Details = new Image_Details();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [imde_id],[imha_id],[imde_sizeH],[imde_sizeL] FROM [Image_Details] WHERE [imde_id]=@imde_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@imde_id",DbType.Int32,imde_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oImage_Details.imde_id = Convert.ToInt32(oDbDataReader["imde_id"]);
					oImage_Details.imha_id = Convert.ToInt32(oDbDataReader["imha_id"]);

					if(oDbDataReader["imde_sizeH"] != DBNull.Value)
						oImage_Details.imde_sizeH = Convert.ToDouble(oDbDataReader["imde_sizeH"]);

					if(oDbDataReader["imde_sizeL"] != DBNull.Value)
						oImage_Details.imde_sizeL = Convert.ToDouble(oDbDataReader["imde_sizeL"]);
				}
				oDbDataReader.Close();
				return oImage_Details;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public List<Alert> GetAlertsOfUser(int user_id)
		{
			try
			{
				List<Alert> lstAlerts = new List<Alert>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [aler_id],[came_id],[aler_dt],[aler_lvl],[aler_status],[aler_image_traj],[vide_id],[aler_image],[imde_id],[user_id] FROM [Alert] WHERE [user_id]=@user_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@user_id",DbType.Int32,user_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					Alert oAlert = new Alert();
					oAlert.aler_id = Convert.ToInt32(oDbDataReader["aler_id"]);

					if(oDbDataReader["came_id"] != DBNull.Value)
						oAlert.came_id = Convert.ToInt32(oDbDataReader["came_id"]);

					if(oDbDataReader["aler_dt"] != DBNull.Value)
						oAlert.aler_dt = Convert.ToDateTime(oDbDataReader["aler_dt"]);

					if(oDbDataReader["aler_lvl"] != DBNull.Value)
						oAlert.aler_lvl = Convert.ToInt32(oDbDataReader["aler_lvl"]);

					if(oDbDataReader["aler_status"] != DBNull.Value)
						oAlert.aler_status = Convert.ToBoolean(oDbDataReader["aler_status"]);

					if(oDbDataReader["aler_image_traj"] != DBNull.Value)
						oAlert.aler_image_traj = Convert.ToString(oDbDataReader["aler_image_traj"]);

					if(oDbDataReader["vide_id"] != DBNull.Value)
						oAlert.vide_id = Convert.ToInt32(oDbDataReader["vide_id"]);

					if(oDbDataReader["aler_image"] != DBNull.Value)
						oAlert.aler_image = Convert.ToString(oDbDataReader["aler_image"]);

					if(oDbDataReader["imde_id"] != DBNull.Value)
						oAlert.imde_id = Convert.ToInt32(oDbDataReader["imde_id"]);

					if(oDbDataReader["user_id"] != DBNull.Value)
						oAlert.user_id = Convert.ToInt32(oDbDataReader["user_id"]);
					lstAlerts.Add(oAlert);
				}
				oDbDataReader.Close();
				return lstAlerts;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public User GetUserOfAlert(int user_id)
		{
			try
			{
				User oUser = new User();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [user_id],[user_name],[user_tel],[user_mail],[user_role],[user_lvl_notif],[user_pwd],[user_login] FROM [User] WHERE [user_id]=@user_id",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@user_id",DbType.Int32,user_id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oUser.user_id = Convert.ToInt32(oDbDataReader["user_id"]);
					oUser.user_name = Convert.ToString(oDbDataReader["user_name"]);
					oUser.user_tel = Convert.ToString(oDbDataReader["user_tel"]);
					oUser.user_mail = Convert.ToString(oDbDataReader["user_mail"]);

					if(oDbDataReader["user_role"] != DBNull.Value)
						oUser.user_role = Convert.ToInt32(oDbDataReader["user_role"]);

					if(oDbDataReader["user_lvl_notif"] != DBNull.Value)
						oUser.user_lvl_notif = Convert.ToInt32(oDbDataReader["user_lvl_notif"]);

					if(oDbDataReader["user_pwd"] != DBNull.Value)
						oUser.user_pwd = Convert.ToString(oDbDataReader["user_pwd"]);

					if(oDbDataReader["user_login"] != DBNull.Value)
						oUser.user_login = Convert.ToString(oDbDataReader["user_login"]);
				}
				oDbDataReader.Close();
				return oUser;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
	}
}
